| - (Subtraction) The subtraction operator is used to subtract the value on the right of the operator from the value on the left. The new value is then stuffed into and replaces the operand on the left. If either of the operand values are a string, it is converted to a number before the subtraction takes place. Do not confuse the use of the subtraction operator with that of the the unary negation operator. While each is the same character, their use differs slightly and their result differs greatly. syntax: numberOne - numberTwo EXAMPLE stringOne = new String("50"); difference = stringOne - 30; document.write(The difference between 50 and 30 is " + difference); There are two variables declared in the above example, stringOne, and difference. Variable "stringOne" is of the string data type, and difference is the value of stringOne, converted to a number, subtracted by 30. The document.write satement is used to write a short burst of text along with the product of the subtraction operator. |